//
//  LSWorkOvertimeApplyViewController.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2019/1/22.
//  Copyright © 2019 wpkj. All rights reserved.
//

#import "LSWorkOvertimeApplyViewController.h"
#import "LSInfoCollectTableViewCell.h"
#import "LSDatePickViewController.h"
#import "NZKTextView.h"

#define FontSize 14

@interface LSWorkOvertimeApplyViewController () <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, UITextViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *tableViewHeaderView;
@property (nonatomic, strong) UIView *tableViewFooterView;
@property (nonatomic, strong) NSArray *contentArray;

@property (nonatomic, strong) NZKTextView *contentTV;
@property (nonatomic, strong) UITextField *postTF;
@property (nonatomic, strong) UITextField *overtimeMemberTF;
@property (nonatomic, strong) UITextField *overtimeTimeLengthTF;
@property (nonatomic, strong) UITextField *overtimeBeginTimeTF;
@property (nonatomic, strong) UITextField *overtimeEndTimeTF;
@property (nonatomic, strong) UITextField *informToTF;

@property (nonatomic, strong) NSArray *informToTFArray;
@property (nonatomic, assign) BOOL isHaveDian;
@end

static NSString *LSInfoCollectTableViewCellID = @"LSInfoCollectTableViewCellID";

@implementation LSWorkOvertimeApplyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"加班申请";
    self.isHaveDian = false;
    [self.view addSubview:self.tableView];
    self.tableView.tableHeaderView = self.tableViewHeaderView;
}

#pragma mark - 提交按钮点击事件
- (void)submitButtonClick {
    if ([self.contentTV.text isEqualToString:@""]) {
        [MBProgressHUD showTipMessageInWindow:@"请输入加班事由"];
        return;
    } else if ([self.postTF.text isEqualToString:@""]) {
        [MBProgressHUD showTipMessageInWindow:@"请选择您的职务"];
        return;
    } else if ([self.overtimeMemberTF.text isEqualToString:@""]) {
        [MBProgressHUD showTipMessageInWindow:@"请输入加班人数"];
        return;
    } else if ([self.overtimeTimeLengthTF.text isEqualToString:@""]) {
        [MBProgressHUD showTipMessageInWindow:@"请输入加班时长"];
        return;
    } else if ([self.overtimeBeginTimeTF.text isEqualToString:@""]) {
        [MBProgressHUD showTipMessageInWindow:@"请选择加班开始时间"];
        return;
    } else if ([self.overtimeEndTimeTF.text isEqualToString:@""]) {
        [MBProgressHUD showTipMessageInWindow:@"请选择加班结束时间"];
        return;
    } else if ([self.informToTF.text isEqualToString:@""]) {
        [MBProgressHUD showTipMessageInWindow:@"请选择是否通知分管领导"];
        return;
    }
    NSMutableDictionary *param = [[NSMutableDictionary alloc] initWithDictionary:@{
                                                                                   @"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token],
                                                                                   @"createBy":[ValidateUtils validateNull:[UserInfoModel sharedInstance].customerNickname],
                                                                                   @"isDeleted":@"0",
                                                                                   @"contactId":[ValidateUtils validateNull:[UserInfoModel sharedInstance].customerId],
                                                                                   @"approveMain":self.contentTV.text,
                                                                                   @"realName":[ValidateUtils validateNull:[UserInfoModel sharedInstance].customerRealName],
                                                                                   @"job":[ValidateUtils validateNull:self.postTF.placeholder],
                                                                                   @"personNum":self.overtimeMemberTF.text,
                                                                                   @"reason":self.contentTV.text,
                                                                                   @"isNotice":[ValidateUtils validateNull:self.informToTF.placeholder],
                                                                                   @"begintime":self.overtimeBeginTimeTF.text,
                                                                                   @"endtime":self.overtimeEndTimeTF.text,
                                                                                   @"duration":[NSString stringWithFormat:@"%.2f",self.overtimeTimeLengthTF.text.floatValue]
                                                                                   }];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:true];
    [NetworkUtils requestNOHandleWithMethod:@"GET" URL:WorkOverTimeApply param:param completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
                [MBProgressHUD showTipMessageInWindow:[ValidateUtils validateNull:[responseObject objectForKey:@"message"]]];
                WS
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    [weakSelf.navigationController popViewControllerAnimated:true];
                });
            } else {
                [MBProgressHUD showTipMessageInWindow:[ValidateUtils validateNull:[responseObject objectForKey:@"message"]]];
            }
        } else {
            [MBProgressHUD showTipMessageInWindow:[NSString stringWithFormat:@"%@",connectionError.localizedDescription]];
        }
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.contentArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    LSInfoCollectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LSInfoCollectTableViewCellID forIndexPath:indexPath];
    cell.leftLabel.text = self.contentArray[indexPath.row];
    [cell.leftLabel sizeToFit];
    
    for (UIView *subView in cell.contentView.subviews) {
        if ([subView isKindOfClass:UITextField.class]) {
            [subView removeFromSuperview];
        }
    }
    
    LSInfoCollectTableViewCell *currentCell = cell;
    if (indexPath.row == 0) {
        [currentCell.contentView addSubview:self.postTF];
        [self.postTF mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(currentCell.leftLabel.mas_right).with.offset(12);
            make.right.equalTo(currentCell.contentView.mas_right).with.offset(-15);
            make.top.equalTo(currentCell.contentView.mas_top).with.offset(8);
            make.bottom.equalTo(currentCell.contentView.mas_bottom);
        }];
    } else if (indexPath.row == 1) {
        [currentCell.contentView addSubview:self.overtimeMemberTF];
        [self.overtimeMemberTF mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(currentCell.leftLabel.mas_right).with.offset(12);
            make.right.equalTo(currentCell.contentView.mas_right).with.offset(-15);
            make.top.equalTo(currentCell.contentView.mas_top).with.offset(8);
            make.bottom.equalTo(currentCell.contentView.mas_bottom);
        }];
    } else if (indexPath.row == 2) {
        [currentCell.contentView addSubview:self.overtimeTimeLengthTF];
        [self.overtimeTimeLengthTF mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(currentCell.leftLabel.mas_right).with.offset(12);
            make.right.equalTo(currentCell.contentView.mas_right).with.offset(-15);
            make.top.equalTo(currentCell.contentView.mas_top).with.offset(8);
            make.bottom.equalTo(currentCell.contentView.mas_bottom);
        }];
    } else if (indexPath.row == 3) {
        [currentCell.contentView addSubview:self.overtimeBeginTimeTF];
        [self.overtimeBeginTimeTF mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(currentCell.leftLabel.mas_right).with.offset(12);
            make.right.equalTo(currentCell.contentView.mas_right).with.offset(-15);
            make.top.equalTo(currentCell.contentView.mas_top).with.offset(8);
            make.bottom.equalTo(currentCell.contentView.mas_bottom);
        }];
    } else if (indexPath.row == 4) {
        [currentCell.contentView addSubview:self.overtimeEndTimeTF];
        [self.overtimeEndTimeTF mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(currentCell.leftLabel.mas_right).with.offset(12);
            make.right.equalTo(currentCell.contentView.mas_right).with.offset(-15);
            make.top.equalTo(currentCell.contentView.mas_top).with.offset(8);
            make.bottom.equalTo(currentCell.contentView.mas_bottom);
        }];
    } else if (indexPath.row == 5) {
        [currentCell.contentView addSubview:self.informToTF];
        [self.informToTF mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(currentCell.leftLabel.mas_right).with.offset(12);
            make.right.equalTo(currentCell.contentView.mas_right).with.offset(-15);
            make.top.equalTo(currentCell.contentView.mas_top).with.offset(8);
            make.bottom.equalTo(currentCell.contentView.mas_bottom);
        }];
    }
    
    return cell;
}

#pragma mark - 弹窗
- (void)showSelectControllerForTextField:(UITextField *)textField WithContentArray:(NSArray <NSDictionary *> *)contentArray showCode:(NSString *)showCode requestCode:(NSString *)requestCode {
    UIAlertController *alertC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    for (int i = 0; i < contentArray.count; i++) {
        [alertC addActionTarget:alertC title:contentArray[i][showCode] color:NAV_COLOR action:^(UIAlertAction *action) {
            textField.text = [ValidateUtils validateNull:contentArray[i][showCode]];
            textField.placeholder = [ValidateUtils validateNull:contentArray[i][requestCode]];
        }];
    }
    [alertC addCancelActionTarget:alertC color:NAV_COLOR title:@"取消"];
    [self presentViewController:alertC animated:true completion:nil];
}

- (void)showDateSelectControllerForTextField:(UITextField *)textField WithTitle:(NSString *)title {
    LSDatePickViewController *alertVC = [LSDatePickViewController alertControllerWithTitle:[NSString stringWithFormat:@"%@\n\n\n\n\n\n\n\n\n\n\n\n",title] message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        // 获取当前datePicker上面选择的时间
        NSDate *date = alertVC.datePicker.date;
        // NSLog(@"-----%@", date);
        // 创建时间格式化工具
        NSDateFormatter *df = [[NSDateFormatter alloc] init];
        df.dateFormat = @"yyyy-MM-dd HH:mm:ss";
        if (textField == self.overtimeBeginTimeTF) {
            if (![self.overtimeEndTimeTF.text isEqualToString:@""]) {
                NSDate *endDate = [df dateFromString:self.overtimeEndTimeTF.text];
                if ([date earlierDate:endDate] == endDate) {
                    [MBProgressHUD showTipMessageInWindow:@"加班开始时间不可晚于加班结束时间"];
                    return;
                }
            }
        } else if (textField == self.overtimeEndTimeTF) {
            if (![self.overtimeBeginTimeTF.text isEqualToString:@""]) {
                NSDate *beginDate = [df dateFromString:self.overtimeBeginTimeTF.text];
                if ([date earlierDate:beginDate] == date) {
                    [MBProgressHUD showTipMessageInWindow:@"加班结束时间不可早于加班开始时间"];
                    return;
                }
            }
        }
        NSString *str = [df stringFromDate:date];
        textField.text = [NSString stringWithFormat:@"%@",str];
        textField.backgroundColor = UIColor.whiteColor;
    }];
    [alertVC addAction:cancelAction];
    [alertVC addAction:okAction];
    [self presentViewController:alertVC animated:YES completion:nil];
}

- (void)requestListForTextField:(UITextField *)textField withURLString:(NSString *)URLString andParam:(NSDictionary *)param listCode:(NSString *)listCode showCode:(NSString *)showCode requestCode:(NSString *)requestCode {
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:URLString param:param completionHandler:^(id responseObject, NSError *connectionError) {
        if (!connectionError) {
            NSLog(@"返回数据----%@",responseObject);
            NSArray *objArray = [responseObject objectForKey:listCode];
            if (objArray && objArray.count > 0) {
                NSMutableArray *objArrayM = [[NSMutableArray alloc] initWithArray:objArray];
                [self showSelectControllerForTextField:textField WithContentArray:objArrayM showCode:showCode requestCode:requestCode];
            }
        } else {
            [MBProgressHUD showTipMessageInWindow:[NSString stringWithFormat:@"%@",connectionError.localizedDescription]];
        }
    }];
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    if (textField == self.postTF) {
        // 请求职务列表
        [self requestListForTextField:self.postTF withURLString:OASjzd andParam:@{@"typeGroupName":@"userDuty",@"token":[ValidateUtils validateNull:[UserInfoModel sharedInstance].token]} listCode:@"obj" showCode:@"typename" requestCode:@"typecode"];
        return false;
    } else if (textField == self.overtimeBeginTimeTF) {
        // 弹出加班开始时间选择框
        [self showDateSelectControllerForTextField:self.overtimeBeginTimeTF WithTitle:@"请选择加班开始时间"];
        return false;
    } else if (textField == self.overtimeEndTimeTF) {
        // 弹出加班结束时间选择框
        [self showDateSelectControllerForTextField:self.overtimeEndTimeTF WithTitle:@"请选择加班结束时间"];
        return false;
    } else if (textField == self.informToTF) {
        // 请求是否通知分管领导
        [self showSelectControllerForTextField:self.informToTF WithContentArray:self.informToTFArray showCode:@"title" requestCode:@"code"];
        return false;
    }
    return true;
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    if (([ValidateUtils isInputRuleNotBlank:text] && ![ValidateUtils hasSpecialString:text]) || [text isEqualToString:@""]) {//当输入符合规则和退格键时允许改变输入框
        return YES;
    } else {
        if (textView == self.contentTV && (text.length == 0 || [text isEqualToString:@""])) return TRUE;
        if (textView == self.contentTV && textView.text.length > 59) return FALSE;
        return TRUE;
    }
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    if (string.length == 0 ||  [string isEqualToString:@""]) return true;// 如果是删除字符，肯定是要通过的
    
    /*
     * 不能输入.0-9以外的字符。
     * 设置输入框输入的内容格式
     * 只能有一个小数点
     * 小数点后最多能输入两位
     * 如果第一位是.则前面加上0.
     * 如果第一位是0则后面必须输入点，否则不能输入。
     */
    
    // 判断是否有小数点
    if ([textField.text containsString:@"."]) {
        self.isHaveDian = true;
    }else{
        self.isHaveDian = false;
    }
    if (string.length > 0) {
        //当前输入的字符
        unichar single = [string characterAtIndex:0];
        // 不能输入.0-9以外的字符
        if (!((single >= '0' && single <= '9') || single == '.'))
        {
            //            [MBProgressHUD bwm_showTitle:@"您的输入格式不正确" toView:self hideAfter:1.0];
            return NO;
        }
        
        // 只能有一个小数点
        if (self.isHaveDian && single == '.') {
            return NO;
        }
        
        // 如果第一位是.则前面加上0.
        if ((textField.text.length == 0) && (single == '.')) {
            textField.text = @"0";
        }
        
        // 如果第一位是0则后面必须输入点，否则不能输入。
        if ([textField.text hasPrefix:@"0"]) {
            if (textField.text.length > 1) {
                NSString *secondStr = [textField.text substringWithRange:NSMakeRange(1, 1)];
                if (![secondStr isEqualToString:@"."]) {
                    //                    [MBProgressHUD bwm_showTitle:@"第二个字符需要是小数点" toView:self hideAfter:1.0];
                    return NO;
                }
            }else{
                if (![string isEqualToString:@"."]) {
                    //                    [MBProgressHUD bwm_showTitle:@"第二个字符需要是小数点" toView:self hideAfter:1.0];
                    return NO;
                }
            }
        }
        
        // 小数点后最多能输入一位
        if (self.isHaveDian) {
            NSRange ran = [textField.text rangeOfString:@"."];
            // 由于range.location是NSUInteger类型的，所以这里不能通过(range.location - ran.location)>2来判断
            if (range.location > ran.location) {
                if ([textField.text pathExtension].length > 1) {
                    //                    [MBProgressHUD bwm_showTitle:@"小数点后最多有两位小数" toView:self hideAfter:1.0];
                    return NO;
                }
            }
        }
    }
    if (range.length == 1 && string.length == 0) {
        return YES;
    } else {
        //否则返回yes,不限制其他textfield
        if ((textField == self.overtimeMemberTF && textField.text.length >= 5)||(textField == self.overtimeTimeLengthTF && textField.text.length >= 5)) {
            textField.text = [textField.text substringToIndex:5];
            return NO;
        }
        if (textField == self.overtimeTimeLengthTF && textField.text.length >= 5) {
            textField.text = [textField.text substringToIndex:5];
            return NO;
        }
    }
    
    if (textField == self.overtimeTimeLengthTF) {
        return [self validateNumberAndDot:string];
    }
    if (textField == self.overtimeMemberTF) {
        return [self validateNumber:string];
    }
    return YES;
}

- (BOOL)validateNumber:(NSString*)number {
    BOOL res =YES;
    NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
    int i =0;
    while (i < number.length) {
        NSString * string = [number substringWithRange:NSMakeRange(i,1)];
        NSRange range = [string rangeOfCharacterFromSet:tmpSet];
        if (range.length ==0) {
            res =NO;
            break;
        }
        i++;
    }
    return res;
}

- (BOOL)validateNumberAndDot:(NSString*)number {
    BOOL res =YES;
    NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789."];
    int i =0;
    while (i < number.length) {
        NSString * string = [number substringWithRange:NSMakeRange(i,1)];
        NSRange range = [string rangeOfCharacterFromSet:tmpSet];
        if (range.length ==0) {
            res =NO;
            break;
        }
        i++;
    }
    return res;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:true];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}

- (NSArray *)contentArray {
    if (!_contentArray) {
        _contentArray = @[@"职务：",@"加班人数：",@"加班时长：",@"加班开始时间：",@"加班结束时间：",@"是否告知分管领导："];
    }
    return _contentArray;
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight)];
        _tableView.separatorInset = UIEdgeInsetsZero;
        _tableView.backgroundColor = hexColor(eeeeee);
        UIView *tableViewFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 100)];
        UIButton *submitButton = [[UIButton alloc] initWithFrame:CGRectMake(15, 30, ScreenWidth-30, 40)];
        [submitButton setTitle:@"提交" forState:UIControlStateNormal];
        [submitButton setTitleColor:hexColor(ffffff) forState:UIControlStateNormal];
        submitButton.titleLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:14];
        submitButton.backgroundColor = hexColor(FDBB2C);
        submitButton.layer.cornerRadius = 4;
        submitButton.layer.masksToBounds = true;
        [submitButton addTarget:self action:@selector(submitButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [tableViewFooterView addSubview:submitButton];
        _tableView.tableFooterView = tableViewFooterView;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        [_tableView registerClass:LSInfoCollectTableViewCell.class forCellReuseIdentifier:LSInfoCollectTableViewCellID];
    }
    return _tableView;
}

- (UIView *)tableViewHeaderView {
    if (!_tableViewHeaderView) {
        _tableViewHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 120+35)];
        _tableViewHeaderView.backgroundColor = hexColor(ffffff);
        [_tableViewHeaderView addSubview:self.contentTV];
        UIImageView *xingImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 11, 35)];
        xingImageView.contentMode = UIViewContentModeCenter;
        xingImageView.image = [UIImage imageNamed:@"xinhao"];
        [_tableViewHeaderView addSubview:xingImageView];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, ScreenWidth-40, 35) andText:@"加班事由：" andTextColor:hexColor(333333) andFont:[UIFont fontWithName:@"SourceHanSansCN-Regular" size:14] andTextAlignment:NSTextAlignmentLeft];
        [_tableViewHeaderView addSubview:label];
    }
    return _tableViewHeaderView;
}

- (NZKTextView *)contentTV {
    if (!_contentTV) {
        _contentTV = [[NZKTextView alloc] initWithFrame:CGRectMake(15, 35, ScreenWidth-30, 120)];
        _contentTV.layer.cornerRadius = 4;
        _contentTV.layer.masksToBounds = true;
        _contentTV.layer.borderWidth = 1;
        _contentTV.layer.borderColor = UIColor.grayColor.CGColor;
        _contentTV.delegate = self;
        _contentTV.placeHolder = @"限制120字以内";
    }
    return _contentTV;
}

- (UITextField *)postTF {
    if (!_postTF) {
        _postTF = [[UITextField alloc] init];
        _postTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:FontSize];
        UIImageView *postTFRightViewImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 44-8, 44-8)];
        postTFRightViewImageView.contentMode = UIViewContentModeCenter;
        postTFRightViewImageView.image = [UIImage imageNamed:@"kuang_xiala"];
        _postTF.rightView = postTFRightViewImageView;
        _postTF.rightViewMode = UITextFieldViewModeAlways;
        _postTF.delegate = self;
    }
    return _postTF;
}

- (UITextField *)overtimeMemberTF {
    if (!_overtimeMemberTF) {
        _overtimeMemberTF = [[UITextField alloc] init];
        _overtimeMemberTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:FontSize];
        _overtimeMemberTF.keyboardType = UIKeyboardTypeNumberPad;
        _overtimeMemberTF.placeholder = @"例如1（人）";
        _overtimeMemberTF.delegate = self;
    }
    return _overtimeMemberTF;
}

- (UITextField *)overtimeTimeLengthTF {
    if (!_overtimeTimeLengthTF) {
        _overtimeTimeLengthTF = [[UITextField alloc] init];
        _overtimeTimeLengthTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:FontSize];
        _overtimeTimeLengthTF.placeholder = @"例如1（小时）";
        _overtimeTimeLengthTF.keyboardType = UIKeyboardTypeDecimalPad;
        _overtimeTimeLengthTF.delegate = self;
    }
    return _overtimeTimeLengthTF;
}

- (UITextField *)overtimeBeginTimeTF {
    if (!_overtimeBeginTimeTF) {
        _overtimeBeginTimeTF = [[UITextField alloc] init];
        _overtimeBeginTimeTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:FontSize];
        UIImageView *overtimeBeginTimeTFRightViewImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 44-8, 44-8)];
        overtimeBeginTimeTFRightViewImageView.contentMode = UIViewContentModeCenter;
        overtimeBeginTimeTFRightViewImageView.image = [UIImage imageNamed:@"xiala"];
        _overtimeBeginTimeTF.rightView = overtimeBeginTimeTFRightViewImageView;
        _overtimeBeginTimeTF.rightViewMode = UITextFieldViewModeAlways;
        _overtimeBeginTimeTF.delegate = self;
    }
    return _overtimeBeginTimeTF;
}

- (UITextField *)overtimeEndTimeTF {
    if (!_overtimeEndTimeTF) {
        _overtimeEndTimeTF = [[UITextField alloc] init];
        _overtimeEndTimeTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:FontSize];
        UIImageView *overtimeEndTimeTFRightViewImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 44-8, 44-8)];
        overtimeEndTimeTFRightViewImageView.contentMode = UIViewContentModeCenter;
        overtimeEndTimeTFRightViewImageView.image = [UIImage imageNamed:@"xiala"];
        _overtimeEndTimeTF.rightView = overtimeEndTimeTFRightViewImageView;
        _overtimeEndTimeTF.rightViewMode = UITextFieldViewModeAlways;
        _overtimeEndTimeTF.delegate = self;
    }
    return _overtimeEndTimeTF;
}

- (UITextField *)informToTF {
    if (!_informToTF) {
        _informToTF = [[UITextField alloc] init];
        _informToTF.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:FontSize];
        UIImageView *informToTFRightViewImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 44-8, 44-8)];
        informToTFRightViewImageView.contentMode = UIViewContentModeCenter;
        informToTFRightViewImageView.image = [UIImage imageNamed:@"kuang_xiala"];
        _informToTF.rightView = informToTFRightViewImageView;
        _informToTF.rightViewMode = UITextFieldViewModeAlways;
        _informToTF.delegate = self;
    }
    return _informToTF;
}

- (NSArray *)informToTFArray {
    if (!_informToTFArray) {
        _informToTFArray = @[@{@"title":@"是",@"code":@"1"},@{@"title":@"否",@"code":@"0"}];
    }
    return _informToTFArray;
}

@end
